#pragma once
#include "base/core/singleton.h"
#include "base/core/script.h"
#include "base/core/buffer_pool.h"
#include "GlobalScriptFunc_LS.h"

class ScriptMgr : public ManualSingleton<ScriptMgr> 
{
    friend class ManualSingleton<ScriptMgr>;

public:
    bool Init();
    bool UnInit();
    bool Update(uint64_t tick);

    bool ResetScriptState(bool reload);
    bool ReloadScriptFile(const char* fileName);
    bool ReLoadScript();
    LuaScript* GetScript();

protected:
    bool _LoadBootScript();
    bool _RegistScriptObject();

protected:
    LuaScript  m_script;
    BufferPool m_memoryPool;

protected:
    ScriptMgr();
    virtual ~ScriptMgr();
};

#define  g_MakeScriptMgr() (ScriptMgr::Instance())
#define  g_GetScriptMgr()  (ScriptMgr::GetInstance())
#define  g_DelScriptMgr()  (ScriptMgr::Destroy())
